package com.huishen.edrivenew.widget;


import java.util.List;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.huishen.edrivenew.R;
import com.huishen.edrivenew.adapter.DialogListApdater;
import com.huishen.edrivenew.bean.PointBean;

/**
 * 自定义消息弹出框
 */
public class MessageListDialog extends Dialog implements View.OnClickListener {
    
    private String title;
    
    private List<PointBean> points;
    
    private TextView tvTitle;
    private TextView tvNumber;
    private TextView tvValue;
    private TextView tvDetial;
    private ImageView line;
    
    private Button commit;
    
    private ListView list;
    DialogListApdater adapter;
    

    public MessageListDialog(Context context, String title, List<PointBean> points) {
        super(context, R.style.dataselectstyle);
        
        this.title = title;
        this.points = points;
    }

    public MessageListDialog(Context context, int theme) {
        super(context, R.style.dataselectstyle);
    }

    public MessageListDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, R.style.dataselectstyle);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.dialog_list);
        registView();
        init();
    }

    private void registView() {
        tvTitle = (TextView) findViewById(R.id.title);
        commit = (Button) findViewById(R.id.dialog_msg_commit);
        list = (ListView) findViewById(R.id.dialog_list);
        line = (ImageView) findViewById(R.id.line);
    }



    private void init() {
        tvTitle.setText(title);
        commit.setOnClickListener(this);
        adapter = new DialogListApdater(getContext(), points);
        list.setAdapter(adapter);
        
        if(points == null || points.size()==0) {
            line.setVisibility(View.INVISIBLE);
        }
    }

    @Override
    public void onClick(View v) {
        dismiss();
    }

}
